package com.extra;

public class Solution14 {
    public String longestCommonPrefix(String[] strs) {
        String res = strs[0];
        for (int i = 1; i < strs.length; i++) {
            int index = 0;
            for (; index < res.length() && index < strs[i].length(); index++) {
                if (res.charAt(index) != strs[i].charAt(index)) break;
            }
            res = res.substring(0, index);
            if (res.equals("")) return res;
        }
        return res;
    }
}
